
import com.br.cashflowdao.hibernate.dao.AccountDAO;
import com.br.cashflowdao.hibernate.dao.GenericDAO;
import com.br.cashflowdao.hibernate.dao.entities.Account;
import com.br.cashflowdao.hibernate.dao.entities.IEntity;
import com.br.cashflowdao.hibernate.dao.factory.DAOFactory;
import com.br.cashflowdao.hibernate.dao.factory.MySqlDAOFactory;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 *
 * @author Marcel Sena <marcel.sena at marcel.sena@gmail.com>
 */
public class Test {

    public static void main (String[] args) {
        create();
    }

    private static void create() {
        DAOFactory factory = DAOFactory.getInstance(MySqlDAOFactory.class);
        GenericDAO genericDAO = factory.getGenericDAO();
        Account acc = new Account();
        acc.setCreateDate(new Date());
        acc.setUpdateDate(new Date());
        acc.setCurrentBalance(new BigDecimal(1000.00).setScale(2));
        acc.setName("Äccount Test One");
        acc.setDescription("Äccount Test One");
        acc.setStartBalance(new BigDecimal(1000.00).setScale(2));
       // genericDAO.createOrUpdate(acc);
        List<IEntity> list = genericDAO.findAll();
        for (IEntity ie : list) {
            Account account = (Account) ie;
            System.out.println("\nFirst test: " + account.getName() + " " + account.getDescription());
        }

        AccountDAO creditDAO = factory.getAccountDAO();
        Account acc1 = creditDAO.findById(new Long(1));
        System.out.println("\n\n\n\nSecond test: " + acc1.getName() + " " + acc1.getDescription());
      //  System.out.println(list.getName() + " " + list.getDescription());
//        for (IEntity entity : list) {
//            Account account = (Account) entity;
//            System.out.println(account.getName() + " " + account.getDescription());
//        }
    }
}
